package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DishMapper {
    @AutoFill(value = OperationType.INSERT)
    void insert(Dish dish);

    /**
     * 菜品分页查询
     * @param dishPageQueryDTO
     * @return
     */
    Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 根据主键查询
     * @param id
     * @return
     */
    @Select("select * from dish where id=#{id};")
    Dish getById(Long id);

    void delete(List<Long> ids);


    long countById(List<Long> ids);

    @AutoFill(value=OperationType.UPDATE)
    void update(Dish dish);

    @Select("select * from dish where category_id=#{categoryId};")
    List<Dish> getByCategoryId(Long categoryId);

    @Select("select image from dish where name=#{name};")
    String getImageByName(String name);

    @Select("select description from dish where name=#{name};")
    String getDescriptionByName(String name);
}
